package com.vogue.supplymall.account.config;

import java.util.List;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.vogue.supplymall.account.shiro.filter.LoginAuthenticationFilter;
import com.vogue.supplymall.account.shiro.filter.MallAuthenticationFilter;
import com.vogue.supplymall.common.config.JacksonConvert;
import com.vogue.supplymall.common.domain.tool.MessageSourceUtils;

@Configuration
@ComponentScan("com.vogue.supplymall.common.domain.tool")
@ComponentScan("com.vogue.supplymall.shop.common")
@ComponentScan("com.vogue.supplymall.shop.domain")
@ComponentScan("com.vogue.supplymall.match.domain")
@ComponentScan("com.vogue.supplymall.order.domain")
@ComponentScan("com.vogue.supplymall.upload.domain")
@ComponentScan("com.vogue.supplymall.order.common")
@MapperScan({"com.vogue.supplymall.account.domain.mapper","com.vogue.supplymall.shop.domain.mapper","com.vogue.supplymall.match.domain.mapper","com.vogue.supplymall.order.domain.mapper"})
@ImportResource(locations = {"classpath:context.xml", "classpath:base-context.xml"})
public class AdminAccountConfig extends WebMvcConfigurerAdapter {

	public static final Logger LOGGER_ADMINACCOUNTCONFIG = LoggerFactory.getLogger(AdminAccountConfig.class);

	@Override
	public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
		JacksonConvert.convert(converters);
	}
    
	@Bean
	public FilterRegistrationBean regAuth(MallAuthenticationFilter filter) {
	    FilterRegistrationBean registration = new FilterRegistrationBean(filter);
	    registration.setEnabled(false);
	    return registration;
	}
	@Bean
	public FilterRegistrationBean regLogin(LoginAuthenticationFilter filter) {
	    FilterRegistrationBean registration = new FilterRegistrationBean(filter);
	    registration.setEnabled(false);
	    return registration;
	}

	
	@Bean(name = "messageSourceUtils")
	public MessageSourceUtils messageSourceUtils() {
		return new MessageSourceUtils("i18n/adminAccountmessages");
	}
}
